package com.main.controller;

import com.main.common.Person;
import com.main.common.Response;
import com.main.entity.User;
import com.main.exception.TooFrequentRequestException;
import com.main.service.UserService;
import com.main.shake.AntiShake;
import com.main.shake.Encrypt;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
@RestController
@Api(tags = "用户管理接口")
public class UserController extends BaseController {
    @Resource
    private UserService userService;
    @AntiShake(value = 1500)
    @RequestMapping("/selectList")
    @ApiOperation(value = "列表",notes = "列表描述")
    public void selectList(HttpServletResponse response) {
        try {
            List<User> userList = userService.selectList();

            // 调用基类中的 streamJsonData 方法
            streamJsonData(response, userList);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @AntiShake(value = 1500)
    @Encrypt
    @RequestMapping("/selectList2")
    @ApiOperation(value = "列表",notes = "列表描述")
    public Response<List<User>> selectList2(HttpServletResponse response) {
            List<User> userList = userService.selectList();
            return Response.success(userList);

    }
}
